const express = require('express');
const app = express();
const port = 8080;

// 导入 cors 中间件 
const cors = require('cors')
// 将 cors 注册为全局中间件 
app.use(cors())

// 配置解析表单数据的中间件
app.use(express.urlencoded({ extended: false }))

// 参照
const showoldInfo = require('./test/showOldPeople')
app.use('/api', showoldInfo)
const createOldInfo = require('./test/createOldPepple')
app.use('/api', createOldInfo)

// test
const testPost = require('./test/testPost')
app.use('/api', testPost)


// 注册，需要传参三个account,code,mail，post请求
const registerWay = require('./router/register')
app.use('/api', registerWay)
// 登录，需要传参三个account,code,post请求
const loginWay = require('./router/login')
app.use('/api', loginWay)

// 个人中心获取用户信息，post请求
const uesrInfo = require('./router/user/userInfo')
app.use('/api', uesrInfo)
// 个人中心更新用户信息，post请求
const updateUser = require('./router/user/updateUser')
app.use('/api', updateUser)
// 个人中心更新用户信息，post请求
const orderUser = require('./router/user/orderUser')
app.use('/api', orderUser)

// 获取商品细节,需要传参id，post请求
const detailInfo = require('./router/detail/details')
app.use('/api', detailInfo)
// 获取tabs页的商品，无需传参，get请求，未测试
const tabsInfo = require('./router/tabs_item')
app.use('/api', tabsInfo)
// 获取home页的商品，无需传参，get请求
const homeInfo = require('./router/home')
app.use('/api', homeInfo)
// 获取admin页的商品信息，无需传参，get请求
const commodityMInfo = require('./router/detail/commodityManagement')
app.use('/api', commodityMInfo)
// admin页面新增商品信息,post请求
const addDetail = require('./router/detail/addDetail')
app.use('/api', addDetail)
// admin页面更新商品信息,post请求
const updateDetail = require('./router/detail/updateDetail')
app.use('/api', updateDetail)
// admin页面删除商品信息,post请求
const deteleDetail = require('./router/detail/deleteDetail')
app.use('/api', deteleDetail)
// admin页面新增订单信息,post请求
const addOrder = require('./router/order/addOrder')
app.use('/api', addOrder)
// admin页面查询所有订单信息,get请求
const orderManagement = require('./router/order/orderManagement')
app.use('/api', orderManagement)
// admin页面删除订单信息,get请求
const deleteOrder = require('./router/order/deleteOrder')
app.use('/api', deleteOrder)

// 文章页面开发,get请求
const articleInfo = require('./router/articles')
app.use('/api', articleInfo)
// 三种酒tab页面开发,get请求
const tabsDataInfo = require('./router/tabs')
app.use('/api', tabsDataInfo)


// 监听端口
app.listen(port, () => {
    console.log(`Server is running on http://localhost:${port}`);
});